Class Result Portal
Filter Class Result
Select criteria to view class academic performance
";
echo "Debug Information:
"; echo "Academic Year: $acyear
"; echo "Term: $term
"; echo "Class: $klass
"; echo "Total Records Found: {$check_result['total_count']}
"; echo "Students: " . count($students) . "
"; echo "Subjects: " . count($subjects) . "
"; if(count($students) > 0) { echo "Student RegNos: "; foreach($students as $student) { echo $student['regno'] . ", "; } echo "
"; } if(count($subjects) > 0) { echo "Subjects: "; foreach($subjects as $subject) { echo $subject['subject'] . ", "; } } echo "
";
// Fetch all marks data for efficient processing
$marks_query = "SELECT * FROM marks
WHERE acyear = :acyear
AND term = :term
AND klass = :klass";
$marks_stmt = $DBcon->prepare($marks_query);
$marks_stmt->execute([
':acyear' => $acyear,
':term' => $term,
':klass' => $klass
]);
$all_marks = $marks_stmt->fetchAll(PDO::FETCH_ASSOC);
// Organize marks by student and subject
$student_marks = [];
$student_totals = [];
$student_averages = [];
foreach($all_marks as $mark) {
$regno = $mark['regno'];
$subject = $mark['subject'];
$test = $mark['test'];
$exam = $mark['exam'];
$total = $test + $exam;
$student_marks[$regno][$subject] = [
'test' => $test,
'exam' => $exam,
'total' => $total
];
// Initialize totals if not set
if(!isset($student_totals[$regno])) {
$student_totals[$regno] = 0;
}
$student_totals[$regno] += $total;
}
// Calculate averages
foreach($student_totals as $regno => $total) {
$subject_count = count($student_marks[$regno]);
$student_averages[$regno] = $subject_count > 0 ? $total / $subject_count : 0;
}
?>
"; echo "Academic Year: $acyear
"; echo "Term: $term
"; echo "Class: $klass
"; echo "Total Records Found: {$check_result['total_count']}
"; echo "Students: " . count($students) . "
"; echo "Subjects: " . count($subjects) . "
"; if(count($students) > 0) { echo "Student RegNos: "; foreach($students as $student) { echo $student['regno'] . ", "; } echo "
"; } if(count($subjects) > 0) { echo "Subjects: "; foreach($subjects as $subject) { echo $subject['subject'] . ", "; } } echo "
Class Result Sheet
Raymond Schools Nkpor
Class Result Sheet
Academic Year
Term
Class
Total Students
Total Subjects
| REG NO | TOTAL SCORE | AVERAGE | |||
|---|---|---|---|---|---|
| Test | Exam | Total | |||
| '-', 'exam' => '-', 'total' => '-']; ?> | |||||
Class Size:
Students
Students
Subjects Offered:
Subjects
Subjects
Academic Year:
Term:
_________________________
Class Teacher
_________________________
Principal
_________________________
Date:
';
echo 'Academic Year: ' . $acyear . '
'; echo 'Term: ' . $term . '
'; echo 'Class: ' . $klass . '
'; echo 'Make sure there are marks entered for this class in the selected academic year and term.'; echo '
';
}
} catch(PDOException $e) {
echo ''; echo 'Term: ' . $term . '
'; echo 'Class: ' . $klass . '
'; echo 'Make sure there are marks entered for this class in the selected academic year and term.'; echo '
Database error: ' . htmlspecialchars($e->getMessage()) . '
';
}
}
?>